package com.stylefeng.guns.modular.hengtuo;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.lang.Console;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.base.tips.ErrorTip;
import com.stylefeng.guns.core.common.Tools.Result;
import com.stylefeng.guns.core.util.Paging;
import com.stylefeng.guns.modular.netcar.model.DriverInf;
import com.stylefeng.guns.modular.netcar.model.VehicleInf;
import com.stylefeng.guns.modular.netcar.service.IDriverInfService;
import com.stylefeng.guns.modular.netcar.service.IVehicleInfService;
import com.stylefeng.guns.modular.netcar.warpper.DriverInfoWarpper;
import com.stylefeng.guns.modular.netcar.warpper.VehicleInfWarpper;
import com.stylefeng.guns.modular.system.model.Org;
import com.stylefeng.guns.modular.system.service.IOrgService;
import com.stylefeng.guns.pojo.LoginVo;
import com.stylefeng.guns.util.Md5Util;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.log4j.Log4j2;
import okhttp3.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.inject.Inject;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;

/**
 * 恒拓App接口
 *
 * @author 张亚林
 * @Date 2018-12-24 10:45
 */
@Controller
@RequestMapping(value = {"/gunsApi/auth/hengtongApp"})
@Api(value = "恒拓App接口", tags = {"恒拓App接口"})
@Log4j2
public class HengTuoAppInterFaceController extends BaseController {
    @Value("${hengtuo.url}")
    private String url;
    @Value("${hengtuo.furl}")
    private String furl;
    @Value("${hengtuo.Content-Type}")
    private String contentType;
    @Value("${hengtuo.Authorization}")
    private String authorization;
    @Inject
    private LoginVo loginVo;
    //远程调用车辆信息接口上下文
    private static final String GET_CAR_URL = "/external/getCars";
    //远程调用司机信息接口上下文
    private static final String GET_DRVIER_URL = "/external/getDriver";
    @Autowired
    private IOrgService orgService;

    @Autowired
    private IVehicleInfService vehicleInfService;

    @Inject
    private IDriverInfService driverInfService;

    @ApiOperation(value = "恒拓接口登录验证", notes = "后台登录验证", httpMethod = "POST")
    @PostMapping(value = "/login", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public Result Login() {
        //链式构建请求
        OkHttpClient okHttpClient = new OkHttpClient();
        RequestBody body = new FormBody.Builder()
                .add("username", loginVo.getUsername())
                .add("password", loginVo.getPassword())
                .add("grant_type", loginVo.getGrant_type())
                .build();

        Request request = new Request.Builder()
                .url(url + "/auth/oauth/token")
                .header("Authorization", authorization)//头信息，多个头信息多次调用此方法即可
                .header("Content-Type", contentType)
                .post(body)
                .build();
        Call call = okHttpClient.newCall(request);
        try {
            Response response = call.execute();
            String result = response.body().string();
            log.info("result={}", result);
            JSONObject jsonObject = JSONUtil.parseObj(result);
            log.info("json={}", jsonObject);
            if (jsonObject != null) {
                int expires = (int) jsonObject.get("expires_in");
                String access_token = (String) jsonObject.get("access_token");
                timedCache.put("accessToken", access_token, expires * 1000);
                return Result.success(jsonObject);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return Result.error(new ErrorTip(400, "登录有误，请确认接口是否通行!"));
    }


    /**
     * 根据部门名称获取驾驶员信息列表
     *
     * @param orderInf
     * @return
     */
    @ApiOperation(value = "根据机构名称获取驾驶员列表", notes = "根据机构名称获取驾驶员列表", httpMethod = "POST")
    @PostMapping(value = "/getDriverInfoListForOrgName", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public Result getDriverInfoListForOrgName(@org.springframework.web.bind.annotation.RequestBody Map<String, Object> map, @ApiParam(name = "pageNum", value = "当前页数", required = true) @RequestParam(value = "pageNum", defaultValue = "1", required = true) Integer pageNum,
                                              @ApiParam(name = "pageSize", value = "每页显示条数", required = true) @RequestParam(value = "pageSize", defaultValue = "1000000", required = true) Integer pageSize) {
        try {
            String message = "";
            List<DriverInf> list = new ArrayList<>();
            interCall(list, map, this.GET_DRVIER_URL, DriverInf.class, pageNum, pageSize);
            List<String> areaList = list.stream().map(DriverInf::getSoId).distinct().collect(Collectors.toList());
            Console.log("恒力拥有机构集合{}", areaList);
            if (!list.isEmpty()) {
                List<DriverInf> filterList = Lists.newArrayList();//过滤数据
                List<DriverInf> alreadyList = Lists.newArrayList();//已同步数据
                List<Map<String, Object>> mList = new ArrayList<>();
                for (DriverInf o : list) {
                    Map map1 = BeanUtil.beanToMap(o);
                    mList.add(map1);
                }
                super.warpObject(new DriverInfoWarpper(mList));
                BeanUtil.setFieldValue(map, "rows", mList);
                String tenantName = (String) map.get("tenantName");
                Wrapper<Org> wrapper = new EntityWrapper<>();
                if (StringUtils.isNotBlank(tenantName)) {
                    wrapper.eq("so_name", tenantName);
                }
                List<Org> orgList = this.orgService.selectList(wrapper);
                if (!orgList.isEmpty()) {
                    //清空现存数据
                    List<Org> sorg = Lists.newArrayList();
                    List<Integer> ids = Lists.newArrayList();
                    if (StringUtils.isNotBlank(tenantName)) {
                        Integer pid = orgList.get(0).getSoId();//父级ID
                        sorg = this.orgService.selectList(new EntityWrapper<Org>().like("so_pids", String.valueOf(pid)).or("so_id", pid));
                        Collections.sort(sorg, Comparator.comparing(Org::getSoId));
                        ids = sorg.stream().map(Org::getSoId).collect(Collectors.toList());
                    } else {
                        sorg = this.orgService.selectList(new EntityWrapper<Org>());
                        Collections.sort(sorg, Comparator.comparing(Org::getSoId));
                        ids = sorg.stream().map(Org::getSoId).collect(Collectors.toList());
                    }
                    alreadyList = this.driverInfService.selectList(new EntityWrapper<DriverInf>().in("so_id", ids));
                    log.info("已存在驾驶员结合{}", alreadyList);
                    BiMap<String, String> mapV = HashBiMap.create();
                    sorg.stream().forEach(item -> {
                        mapV.put(String.valueOf(item.getSoId()), item.getSoName());
                    });
                    BiMap<String, String> filelogMap = mapV.inverse();//键值转换
                    //清空现存数据
                    Console.log("本地所有机构列表{}", mapV);
                    filterList = list.stream().filter(s -> (StringUtils.isNotBlank(filelogMap.get(s.getSoId())) && StringUtils.isNotBlank(s.getDiName()) && StringUtils.isNotBlank(s.getDiPhone()) && StringUtils.isNotBlank(s.getDiLicenseNo()))).collect(Collectors.toList());
                    filterList.stream().forEach(item -> {
                        String salt = RandomUtil.randomString(8);
                        BeanUtil.setFieldValue(item, "diId", RandomUtil.randomString(32));
                        BeanUtil.setFieldValue(item, "soId", filelogMap.get(item.getSoId()));
                        BeanUtil.setFieldValue(item, "diSalt", salt);
                        BeanUtil.setFieldValue(item, "diIsAlived", "1");
                        BeanUtil.setFieldValue(item, "diPassword", Md5Util.md5(StringUtils.substring(StringUtils.trimToNull(item.getDiPhone()), -6), salt));
                    });
                }
                List<String> aList = filterList.stream().map(DriverInf::getDiPhone).collect(Collectors.toList());
                List<String> bList = alreadyList.stream().map(DriverInf::getDiPhone).collect(Collectors.toList());
                aList.retainAll(bList);//交集
                filterList = filterList.stream().filter((DriverInf b) -> !aList.contains(b.getDiPhone())).collect(Collectors.toList());
                log.info("需要插入的司机信息集合{}", filterList);
                if (!filterList.isEmpty()) {
                    //不存在  插入
                    boolean b = this.driverInfService.insertBatch(filterList);
                    //存在  更新

                    if (b) {
                        log.info("批量同步数据{}集合成功！", filterList);
                        message = "批量同步数据成功，本次同步数据量" + filterList.size() + "条!";
                    } else {
                        log.error("批量同步数据{}集合成功！", filterList);
                        message = "批量同步数据失败，待同步数据量" + filterList.size() + "条!";

                    }
                } else {
                    message = "本次没有待同步数据，请过段时间再试!";
                }
            }
            return Result.success(message);
        } catch (Exception e) {
            return Result.error(new ErrorTip(500100, "获取任务详情列表失败!"));
        }
    }

    @ApiOperation(value = "根据机构名称获取车辆列表", notes = "根据机构名称获取车辆列表", httpMethod = "POST")
    @PostMapping(value = "/GetCarInfoListByOrgName", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public Result GetCarInfoListByOrgName(@org.springframework.web.bind.annotation.RequestBody Map<String, Object> map,
                                          @ApiParam(name = "pageNum", value = "当前页数", required = true) @RequestParam(value = "pageNum", defaultValue = "1", required = true) Integer pageNum,
                                          @ApiParam(name = "pageSize", value = "每页显示条数", required = true) @RequestParam(value = "pageSize", defaultValue = "1000000", required = true) Integer pageSize) {
        try {
            String message = "";
            List<VehicleInf> list = new ArrayList<>();
            interCall(list, map, this.GET_CAR_URL, VehicleInf.class, pageNum, pageSize);
            List<VehicleInf> alreadyList = Lists.newArrayList();//已同步数据
            if (!list.isEmpty()) {
                List<Map<String, Object>> mList = new ArrayList<>();
                for (VehicleInf o : list) {
                    Map map1 = BeanUtil.beanToMap(o);
                    mList.add(map1);
                }
                super.warpObject(new VehicleInfWarpper(mList));
                BeanUtil.setFieldValue(map, "rows", mList);

                String tenantName = (String) map.get("tenantName");
                Wrapper<Org> wrapper = new EntityWrapper<>();
                if (StringUtils.isNotBlank(tenantName)) {
                    wrapper.eq("so_name", tenantName);
                }
                List<Org> orgList = this.orgService.selectList(wrapper);
                if (!orgList.isEmpty()) {
                    List<Org> sorg = Lists.newArrayList();
                    List<Integer> ids = Lists.newArrayList();
                    if (StringUtils.isNotBlank(tenantName)) {
                        Integer pid = orgList.get(0).getSoId();//父级ID
                        sorg = this.orgService.selectList(new EntityWrapper<Org>().like("so_pids", String.valueOf(pid)).or("so_id", String.valueOf(pid)));
                        Collections.sort(sorg, Comparator.comparing(Org::getSoId));
                        ids = sorg.stream().map(Org::getSoId).collect(Collectors.toList());
                    } else {
                        sorg = this.orgService.selectList(new EntityWrapper<Org>());
                        Collections.sort(sorg, Comparator.comparing(Org::getSoId));
                        ids = sorg.stream().map(Org::getSoId).collect(Collectors.toList());
                    }
                    BiMap<String, String> mapV = HashBiMap.create();
                    sorg.stream().forEach(item -> {
                        mapV.put(String.valueOf(item.getSoId()), item.getSoName());
                    });
                    Console.log("本地已有机构列表: [{}],总条数[{}]", JSONUtil.parseFromMap(mapV), mapV.size());
                    List<String> collect = list.stream().map(VehicleInf::getSoId).map(String::trim).distinct().collect(Collectors.toList());
                    Console.log("待同步机构列表: [{}],总条数[{}]", JSONUtil.parse(collect), collect.size());
                    alreadyList = this.vehicleInfService.selectList(new EntityWrapper<VehicleInf>().in("so_id", ids));
                    BiMap<String, String> filelogMap = mapV.inverse();//键值转换
                    list = list.stream().filter(s -> (StringUtils.isNotBlank(filelogMap.get(s.getSoId())))).collect(Collectors.toList());
                    list.stream().forEach(item -> {
                        BeanUtil.setFieldValue(item, "viId", RandomUtil.randomString(32));
                        BeanUtil.setFieldValue(item, "soId", filelogMap.get(item.getSoId()));
                        BeanUtil.setFieldValue(item, "viIsAlived", "1");
                        BeanUtil.setFieldValue(item, "createUser", "恒拓同步");
                        BeanUtil.setFieldValue(item, "createTime", DateTime.now());
                    });
                }
            }
            Collections.sort(list, Comparator.comparing(VehicleInf::getViVehiclePlate).thenComparing(VehicleInf::getViPlateColor));
            Collections.sort(alreadyList, Comparator.comparing(VehicleInf::getViVehiclePlate).thenComparing(VehicleInf::getViPlateColor));
            List<String> aList = list.stream().map(VehicleInf::getViVehiclePlate).collect(Collectors.toList());
            List<String> bList = alreadyList.stream().map(VehicleInf::getViVehiclePlate).collect(Collectors.toList());
            aList.retainAll(bList);//求交集
            list = list.stream().filter((VehicleInf b) -> !aList.contains(b.getViVehiclePlate())).collect(Collectors.toList());
            if (!list.isEmpty()) {
                boolean b = this.vehicleInfService.insertBatch(list);
                if (b) {
                    Console.log("批量同步增量数据: [{}],总条数[{}]", JSONUtil.parse(list), list.size());
                    message = "批量同步增量数据" + list.size() + "条成功!";
                } else {
                    Console.log("批量同步增量数据: [{}]集合失败,总条数[{}]", JSONUtil.parse(list), list.size());
                    message = "批量同步增量数据" + list.size() + "条失败!";
                }
            } else {
                message = "没有待同步数据,请过段时间再试!";
            }
            return Result.success(message);
        } catch (Exception e) {
            return Result.error(new ErrorTip(500100, "获取获取车辆列表失败!"));
        }

    }


    @ApiOperation(value = "根据机构名称获取车辆列表", notes = "根据机构名称获取车辆列表", httpMethod = "POST")
    @PostMapping(value = "/GetCarInfoListByOrgNameBYFront", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public Result GetCarInfoListByOrgNameBYFront(@org.springframework.web.bind.annotation.RequestBody Map<String, Object> map,
                                                 @ApiParam(name = "pageNum", value = "当前页数", required = true) @RequestParam(value = "pageNum", defaultValue = "1", required = true) Integer pageNum,
                                                 @ApiParam(name = "pageSize", value = "每页显示条数", required = true) @RequestParam(value = "pageSize", defaultValue = "1000000", required = true) Integer pageSize) {
        try {
            List<VehicleInf> list = new ArrayList<>();
            interCall(list, map, this.GET_CAR_URL, VehicleInf.class, pageNum, pageSize);
            Paging paging = Paging.pagination(list.size(), pageSize, pageNum);
            int fromIndex = paging.getQueryIndex();
            int toIndex = 0;
            if (fromIndex + paging.getPageSize() >= list.size()) {
                toIndex = list.size();
            } else {
                toIndex = fromIndex + paging.getPageSize();
            }
            if (fromIndex > toIndex) {
                return Result.success(Collections.EMPTY_LIST);
            }
            return Result.success(list.subList(fromIndex, toIndex));
        } catch (Exception e) {
            return Result.error(new ErrorTip(500100, "获取获取车辆列表失败!"));
        }

    }


    /**
     * 驾驶员返回map字段映射
     * 恒拓 对应  成为 字段
     *
     * @return
     */
    private static Map<String, String> getDriverMappingMap() {
        Map<String, String> map = new HashMap<String, String>() {
            {
                put("id", "diId");//司机ID
                put("registerDate", "createTime");
                put("driverName", "diName");
                put("driverGender", "diSex");
                put("areaName", "regionCode");
                put("driverType", "diLicenseType");
                put("idNo", "diLicenseNo");
                put("driverPhone", "diPhone");
                put("tenantName", "soId");
                put("getDriverLicenseDate", "diFirstObtainDate"); //初次领证日期
                put("driverLicensePhoto1", "diLicenseFrontPhoto");//驾照正面照片路径
                put("driverLicensePhoto2", "diLicenseBackPhoto"); //驾照反面照片路径
                put("photo", "diIcon"); //司机头像地址
                put("networkCarProofOn", "diCertificateStartDate"); //从业资格证有效期-开始日期
                put("networkCarProofOff", "diCertificateEndDate"); //从业资格证有效期-截止日期
                put("joinWithCar", "diJoinCar"); //加盟状态：1,有车加盟;2,无车加盟;3,加盟后租车等
            }
        };
        return map;
    }

    /**
     * 机动车返回map字段映射
     * 恒拓 对应  成为 字段
     *
     * @return
     */
    private static Map<String, String> getCarMappingMap() {
        Map<String, String> map = new HashMap<String, String>() {
            {
                put("id", "viId");//司机ID
                put("id", "viCode");//车辆内部编码
                put("vehicleNo", "viVehiclePlate");
                put("vehicleColor", "viVehicleColor");
                put("vehicleNoColor", "viPlateColor");
                put("brand", "viBrand");
                put("model", "viModel");
                put("vehicleType", "viVehicleType");
                put("useNature", "viVehicleUseType");
                put("seats", "viMaxCount");
                put("operational", "viCurrentAccount");
                put("vehicleWheelBase", "viWheelBase");
                put("vehiclePriceWithTax", "viPriceWithTax");
                put("engineId", "viEngineId");
                put("vin", "viVin");
                put("ownType", "viOwntype");
                put("tenantName", "soId");
            }
        };
        return map;
    }

    /**
     * 根据部门名称获取驾驶员信息列表
     *
     * @param orderInf
     * @return
     */
    @ApiOperation(value = "根据机构名称获取驾驶员列表", notes = "根据机构名称获取驾驶员列表", httpMethod = "POST")
    @PostMapping(value = "/getDriverInfoListForOrgNameBYFront", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public Result getDriverInfoListForOrgNameBYFront(@org.springframework.web.bind.annotation.RequestBody Map<String, Object> map, @ApiParam(name = "pageNum", value = "当前页数", required = true) @RequestParam(value = "pageNum", defaultValue = "1", required = true) Integer pageNum,
                                                     @ApiParam(name = "pageSize", value = "每页显示条数", required = true) @RequestParam(value = "pageSize", defaultValue = "1000000", required = true) Integer pageSize) {
        try {

            List<DriverInf> list = new ArrayList<>();
            interCall(list, map, this.GET_DRVIER_URL, DriverInf.class, pageNum, pageSize);
            Paging paging = Paging.pagination(list.size(), pageSize, pageNum);
            int fromIndex = paging.getQueryIndex();
            int toIndex = 0;
            if (fromIndex + paging.getPageSize() >= list.size()) {
                toIndex = list.size();
            } else {
                toIndex = fromIndex + paging.getPageSize();
            }
            if (fromIndex > toIndex) {
                return Result.success(Collections.EMPTY_LIST);
            }
            return Result.success(list.subList(fromIndex, toIndex));
        } catch (Exception e) {
            return Result.error(new ErrorTip(500100, "获取任务详情列表失败!"));
        }
    }

    /**
     * @param list         需要返回的list
     * @param parameterMap 参数Map
     * @param context      接口地址调用URL
     * @param map          字段映射Map
     */
    public void interCall(List list, Map<String, Object> parameterMap, String context, Class<?> clazz, int pageNum, int pageSize) {
        String tenantName = (String) parameterMap.get("tenantName");
        Map<String, String> kv = Maps.newHashMap();//本地机构id 机构名称键值对
        List<String> names = Lists.newArrayList();
        if (StringUtils.isNotBlank(tenantName)) {
            Wrapper<Org> wrapper = new EntityWrapper<>();
            wrapper.eq("so_name", tenantName);
            Org org = this.orgService.selectOne(wrapper);
            Integer pid = org.getSoId();
            List<Org> sorg = this.orgService.selectList(new EntityWrapper<Org>().like("so_pids", String.valueOf(pid)).or("so_id", String.valueOf(pid)));
            Collections.sort(sorg, Comparator.comparing(Org::getSoId));
            names = sorg.stream().map(Org::getSoName).collect(Collectors.toList());
        } else {
            List<Org> orgList = this.orgService.selectList(new EntityWrapper<Org>());
            orgList.stream().forEach(item -> {
                kv.put(String.valueOf(item.getSoId()), item.getSoName());
            });
            MapUtil.reverse(kv);
        }

        String type = (String) parameterMap.get("type");//0  查询当前部门及其子部门 1 只查询当前部门
        String vehicleNo = (String) parameterMap.get("vehicleNo");//车牌号
        String accessToken = timedCache.get("accessToken");
        String className = clazz.getName();
        if (StringUtils.isBlank(accessToken)) {
            Login();//token 失效 再次登录
            accessToken = timedCache.get("accessToken");
        }
        //链式构建请求(根据部门名称获取获取驾驶员列表信息)
        OkHttpClient okHttpClient = new OkHttpClient();
        FormBody.Builder formBody = new FormBody.Builder()
                .add("type", type);
        if (!tenantName.isEmpty())
            formBody.add("tenantName", CollectionUtil.join(names, ","));
        if (StringUtils.isNotBlank(vehicleNo))
            formBody.add("vehicleNo", vehicleNo);
        if (pageNum != 0) {
            formBody.add("pageNum", String.valueOf(pageNum));
        }
        if (pageSize != 0) {
            formBody.add("pageSize", String.valueOf(pageSize));
        }
        RequestBody body = formBody.build();
        Request request = new Request.Builder()
                .url(furl + context)
                .header("Authorization", "Bearer " + accessToken)//头信息，多个头信息多次调用此方法即可
                // .header("x-tenant-flag", "1")
                .post(body)
                .build();
        Call call = okHttpClient.newCall(request);
        try {
            Response response = call.execute();
            String result = response.body().string();
            JSONObject jsonObject = JSONUtil.parseObj(result);
            if (jsonObject != null) {
                int code = (int) jsonObject.get("code");
                if (code == 0) {
                    JSONObject data = (JSONObject) jsonObject.get("data");
                    parameterMap.put("total", data.get("total"));
                    parameterMap.put("page", data.get("page"));
                    parameterMap.put("pageCount", data.get("pageCount"));
                    JSONArray arr = data.getJSONArray("rows");
                    if (arr != null && arr.size() > 0) {
                        arr.forEach(item -> {//遍历data数组 转成driverInf 对象
                            if (StringUtils.endsWithIgnoreCase(className, "DriverInf")) {
                                DriverInf driverInf = new DriverInf();
                                BeanUtil.copyProperties(item, driverInf, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true).setIgnoreCase(true).setFieldMapping(getDriverMappingMap()));
                                list.add(driverInf);
                            } else if (StringUtils.endsWithIgnoreCase(className, "VehicleInf")) {
                                VehicleInf vehicleInf = new VehicleInf();
                                BeanUtil.copyProperties(item, vehicleInf, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true).setIgnoreCase(true).setFieldMapping(getCarMappingMap()));
                                list.add(vehicleInf);
                            } else {
                            }
                        });

                    }
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
